import inherits from "inherits";

import Viewer from "bpmn-js/lib/Viewer";

import ZoomScrollModule from "diagram-js/lib/navigation/zoomscroll";
import MoveCanvasModule from "diagram-js/lib/navigation/movecanvas";
import MinimapModule from "diagram-js-minimap";
// 流程模拟
import TokenSimulationModule from 'bpmn-js-token-simulation/lib/viewer';
// 语言
import customTranslate from '../additional-modules/Translate/customTranslate'
//
import Modeling from 'bpmn-js/lib/features/modeling';

/**
 * 自定义Viewer
 * @param options  Viewer 配置
 * @param customOptions 自定义配置
 * @constructor
 */
function CustomViewer(options, customOptions) {
    let additionalModules = [];
    if(customOptions.loadZoomScrollModule){
        additionalModules.push(ZoomScrollModule);
    }
    if(customOptions.loadMoveCanvasModule){
        additionalModules.push(MoveCanvasModule);
    }
    if(customOptions.loadSimulationModule){
        additionalModules.push(TokenSimulationModule);
    }
    if(customOptions.loadMinimapModule){
        additionalModules.push(MinimapModule);
    }
    // 自定义模块
    if(customOptions.modules && customOptions.modules.length > 0){
        additionalModules.push(...customOptions.modules);
    }
    options.additionalModules = additionalModules;
    Viewer.call(this, options);
}

inherits(CustomViewer, Viewer);

CustomViewer.prototype._modules = [].concat(Viewer.prototype._modules, [
    // ZoomScrollModule,
    // MoveCanvasModule,
    // minimapModule,
    // TokenSimulationModule,
    Modeling,
    // 汉化模块
    {translate: ["value", customTranslate]},
]);

export default CustomViewer;
